import service from '@/service/request';

// 手机密码登录
interface phoneAndPassword {
  phone: number;
  password: string;
}
export function phoneLoginByPassword(params: phoneAndPassword) {
  return service({
    url: '/login/cellphone',
    params: params,
  });
}

// 邮箱密码登录
interface emailAndPassword {
  email: string;
  password: string;
}
export function emailLoginByPassword(params: emailAndPassword) {
  return service({
    url: '/login',
    params: params,
  });
}

// 刷新登录
export function refreshLogin() {
  return service({
    url: '/login/refresh',
  });
}
// 手机号发送验证码  /captcha/sent
export function sentCaptchaByPhone(phone: number, ctcode?: string) {
  return service({
    url: '/captcha/sent',
    params: {
      phone,
      ...(ctcode ? { ctcode } : {}),
    },
  });
}
// 手机号验证验证码
export function verifyCaptcha(phone: number, captcha: string, ctcode?: number) {
  return service({
    url: '/captcha/verify',
    params: {
      phone,
      captcha,
      ...(ctcode ? { ctcode } : {}),
    },
  });
}
// 退出登录
export function logout() {
  return service({
    url: '/logout',
  });
}

// 登录状态

export function loginStatus() {
  return service({
    url: '/login/status',
  });
}
